define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'sys/synlogs/index' + location.search,
                    export_url: 'sys/synlogs/export',
                    table: 'sys_synlogs',
                }
            });

            var table       = $("#table");
            var showExport  = $(".btn-export").data('value')

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                search:false,
                fixedColumns: true,
                fixedRightNumber: 1,
                showToggle: false,
                showExport: showExport,
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID',operate:false},
                        {
                            field: 'forgid', title: __('数据中心/组织'), searchList: function (column) {
                                return Template('forgidtpl', {});
                            }, formatter: function (value, row, index) {
                                return '无';
                            }, visible: false
                        },

                        {field: 'datacenter.fname', title: '数据中心名称',operate: false},
                        {field: 'forg.fname', title: '组织名称',operate: false},
                        {field: 'forg.fnumber', title: '组织编码',operate: false},
                        {field: 'forg.id', title: '组织ID',operate: false},

                        {field: 'fk_bdl_url', title: '接口URL', operate: 'LIKE'},
                        {field: 'fk_bdl_callmethod', title: '调用方法',operate: 'LIKE'},
                        {field: 'fk_bdl_username', title: '调用者', operate: 'LIKE'},
                        {field: 'fk_bdl_comment', title: '备注', operate: 'LIKE'},
                        {field: 'fk_bdl_status', title: '调用状态', searchList: {"true":'成功',"false":'失败'}, formatter: Table.api.formatter.status}  ,
                        {field: 'fk_bdl_exceptionmsg', title: '异常信息', operate: 'LIKE'},

                        {field: 'fk_bdl_calltime', title: '调用时间', operate:'RANGE', autocomplete:false},
                        {field: 'fk_bdl_endtime', title: '结束时间', operate:'RANGE', autocomplete:false},
                        {field: 'fk_bdl_duration', title: '耗时(ms)', operate: 'LIKE'},

                        {field: 'fk_bdl_executetype', title: '执行方式', searchList: {"1":'手动执行',"2":'系统执行'}, formatter: Table.api.formatter.status}  ,
                        {field: 'fk_bdl_successnums', title: '成功条数', operate: 'LIKE'},
                        {field: 'fk_bdl_failnums', title: '失败条数', operate: 'LIKE'},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };


    return Controller;
});
